#include "sched.h"
#include "screen.h"
#include "stdio.h"
#include "syscall.h"
#include "time.h"
#include "mm.h"
#include "test4.h"

#define RW_TIMES 2
int atoi(char *input)
{
}

uint64_t rand()
{

	uint64_t current_time = sys_get_timer();

	return current_time % 100000;
}

void rw_task1(uint64_t arg0, uint64_t arg1)
{
	uint64_t mem1, mem2 = 0;
	int curs = 0;
	int memory[RW_TIMES * 2];
	uint64_t argv[2 * RW_TIMES];
	argv[0] = arg0;
	argv[1] = arg1;
	argv[2] = arg0;
	argv[3] = arg1;

	int i = 0, j = 0;

	for (i = 0; i < RW_TIMES; i++)
	{
		mem1 = argv[i];
		memory[i] = mem2 = rand();
		*(uint64_t *)mem1 = mem2;
		printf("Write: 0x%x,%x\n", mem1, mem2);
	}
	curs = RW_TIMES;
	for (i = 0; i < RW_TIMES; i++)
	{
		sys_move_cursor(1, curs + i);
		mem1 = argv[RW_TIMES + i];

		memory[i + RW_TIMES] = *(uint64_t *)mem1;
		if (memory[i + RW_TIMES] == memory[i])
			printf("Read succeed: 0x%x,%x", mem1, memory[i + RW_TIMES]);
		else
			printf("Read error: 0x%x,%x", mem1, memory[i + RW_TIMES]);
	}
	sys_exit();
}
